<!-- 我的粉丝 -->
<template>
	<view class="page">
		<status-bar :title='title?title:"我的会员"'></status-bar>
		<view class="menuList" v-if='commission.length>0'>
			<view class="nav_top_box" :style="{top:navHeight+System.statusBarHeight+'px'}">
				<view class="navlists" :style="{'--color': color}" v-if="commission.length>0"
					:class="navTab==1?'navAction thmeColor':''" @click="navclick(1,0)">
					<text>{{level_name[0].name}}（{{commission[0]?commission[0].length:0}}）</text>
				</view>
				<view class="navlists" :style="{'--color': color}" v-if="commission.length>1"
					:class="navTab==2?'navAction thmeColor':''" @click="navclick(2,1)">
					<text>{{level_name[1].name}}（{{commission[1]?commission[1].length:0}}）</text>
				</view>
				<view class="navlists" :style="{'--color': color}" v-if="commission.length>2"
					:class="navTab==3?'navAction thmeColor':''" @click="navclick(3,2)">
					<text>{{level_name[2].name}}（{{commission[2]?commission[2].length:0}}）</text>
				</view>
				<view class="Advertising_article thmeBg thmeColor" :style="{'--color': color, left: 33*(navTab - 1) + '%'}">
				</view>
			</view>
		</view>
		<view class="type2" v-if='list && list.length > 0'>
			<view class="item flex-box" v-for="(item,index) in list" :key="index">
				<image class="friHead" @error="item.v_headimg = ''"
					:src="item.v_headimg?item.v_headimg:staticUrl+'/images/jh_up/head.jpg'" mode=""></image>
				<view class="flex">
					<view class="d-flex a-center j-sb">
						<view class="d-flex a-center">
							<text class="name">{{item.v_name}}</text>
							<text class="id">（{{item.v_tel}}）</text>
						</view>
						<view class="color_33 h6">{{item.roleLevelName}}</view>
					</view>
					<view class="time">{{item.v_addtime}}</view>
					<view class="num-list flex-box">
						<view class="num" @click.stop="toUrl(`selfShop?down_v_id=${item.v_id}`)">自购：{{item.orders}}</view>
						<view class="num" @click.stop="toUrl(`Fandetails?down_v_id=${item.v_id}`)">团队数：{{item.members}}</view>
						<view class="num" @click.stop="toUrl(`Scoredetail?down_v_id=${item.v_id}&Status=1`)">
							团队单量：{{item.orders_num}}</view>
						<view class="num" @click.stop="toUrl(`Scoredetail?down_v_id=${item.v_id}&Status=2`)">
							团队业绩：{{item.cumulative_income}}</view>
					</view>
				</view>
			</view>
		</view>
		<empty v-else type='1' cat='3' :msg='"你还没有该信息内容哟~"'></empty>
	</view>
</template>

<script>
	import { mapState } from 'vuex';
	export default {
		data() {
			return {
				title: '',
				navTab: 1,
				staticUrl: this.staticUrl,
				toTop: false,
				brokerage_list: [],
				noData: false,

				commission: [],
				list: '',
				msg: '一',

				state: '', // 我的团队
				level_name: [],
			}
		},



		onLoad(e) {
			if (e.state == 1) {
				this.title = "我的团队";
				this.state = e.state;
			}
		},
		onShow() {
			if (this.state == 1) {
				this.my_income_team();
			} else {
				this.my_income();
			}

		},
		methods: {
			navclick(i, positions) {
				if (positions == 0) {
					this.msg = '一'
				}
				if (positions == 1) {
					this.msg = '二'
				}
				if (positions == 2) {
					this.msg = '三'
				}
				this.list = this.commission[positions]
				this.navTab = i;
			},

			//  我的会员
			my_income() {
				this.$http.post({
					url: '/zzj_singleSaleApi/distribution_people',

				}).then(res => {
					this.commission = res.data;
					this.level_name = res.level_name;
					if (res.data[0]) {
						this.list = res.data[0]
					}
				})
			},

			//  我的团队
			my_income_team() {
				this.$http.post({
					url: '/zzj_singleSaleApi/distribution_people_team',

				}).then(res => {
					if (res.errcode == "100") {
						this.commission = res.data;
						if (res.data[0]) {
							this.list = res.data[0]
						}
					} else {
						uni.showToast({
							title: res.msg,
							icon: "none"
						})
					}

				})
			},
		},
		onShareAppMessage(option) {
			return {
				title: this.share.title,
				desc: this.share.desc,
				path: '/pages/index/index?share_v_id=' + this.vid + '&pageType=99',
				imageUrl: this.share.imageUrl
			}
		},
		computed: {
			...mapState(['tabTitle', 'color', 'city', 'navHeight', 'System', 'share', 'vid']),
		},
	}
</script>

<style scoped lang="scss">
	.right {
		float: right;
	}

	.page {
		background-color: #F8F8F8;

		.nav_top_box {
			width: 100%;
			height: 80upx;
			background: #FFFFFF;
			line-height: 80upx;
			font-size: 28upx;
			color: #333333;
			position: fixed;
			top: 0;
			left: 0;
			right: 0;
			z-index: 99;
			box-shadow: 0 0 5px 0px rgba(0, 0, 0, .1);

			.navlists {
				width: 33%;
				display: inline-block;
				text-align: center;
				color: #999999;
				font-size: 24upx;

				&.navAction {
					position: relative;
					font-weight: bold;
					font-size: 40upx;
					color: #222222;
				}
			}

			.Advertising_article {
				width: 30upx;
				height: 6upx;
				position: absolute;
				bottom: 0;
				transition: left .2s;
				border-radius: 6upx;
				background-color: #222222;
				transform: translateX(106rpx);
			}
		}

		// 样式二
		.type2 {
			padding: 20rpx;
			padding-top: 100upx;

			.item {
				background-color: #FFFFFF;
				padding: 20rpx;
				border-radius: 8rpx;
				margin-bottom: 20rpx;

				.friHead {
					border-radius: 50%;
					height: 64rpx;
					width: 64rpx;
					margin-right: 20rpx;
				}

				.name {
					font-size: 28rpx;
					font-weight: bold;
				}

				.id {
					font-size: 28rpx;
					color: #999999;
				}

				.time {
					color: #999999;
					margin-top: 4rpx;
				}

				.num-list {
					flex-wrap: wrap;
					padding: 20rpx;
					padding-bottom: 0;
					margin-top: 20rpx;
					background-color: #F5F5F5;
					border-radius: 8rpx;

					.num {
						width: 50%;
						margin-bottom: 20rpx;
						color: #333333;
						font-size: 26rpx;
					}
				}
			}
		}
	}
</style>